cd "your file location here"

use "ERAS20_24.dta"

tabstat perc_dec if ban_state==1, by(Year)
tabstat perc_dec if ban_state==0, by(Year)
tabstat perc_dec, by(Year)



tabstat number_applications, by(statecode) 


tabstat n_decline number_applications if Year>22, by(ban_now)

tabstat n_decline number_applications if Year<23, by(ban_state)

**use didreg because this is actually panel data 

eststo: didregress (number_applications) (ban_now2), group(statecode) time(Year)


*models are equivalent to: xtreg number_applications (ban_now2) i.Year, fe vce(cluster statecode)

esttab using residency.tex, replace 

estat trendplots, ytitle(Number of Applications) 

graph save applications_xtdid.gph, replace 
graph export "applications_xtdid.pdf", as(pdf) replace 

estat ptrends 


*manual regression for pre and post ban
sort statecode Year

xtreg number_applications ban_now2 i.Year, fe vce(cluster statecode)


*test differences prior to Dobbs - not significant 
eststo clear 
eststo: xtreg number_applications ban_state i.Year if Year<23, vce(cluster statecode)



*significant after Dobbs 
eststo: xtreg number_applications ban_state i.Year if Year>22, vce(cluster statecode)





esttab using residency_app1.tex, replace 




***alternative coding of ban 

eststo clear 

eststo: didregress (number_applications) (ban_now), group(statecode) time(Year)

esttab using residency_app2.tex


clear  






